﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OrderSystemApi.Pojo
{
    [SugarTable("orderdetails")]
    public class OrderDetails
    {
        [SugarColumn(IsPrimaryKey = true)]
        public long Id { get; set; }
        [SugarColumn(ColumnName = "GoodsId")]
        public long GoodsId { set; get; }
        [SugarColumn(IsIgnore = true)]
        public Goods Goods { set; get; }
        [SugarColumn(ColumnName = "GoodsNum")]
        public int GoodsNum { set; get; }
        [SugarColumn(ColumnName = "OrderId")]
        public long OrderId { get; set; }
        public OrderDetails() { }
        public override string ToString()
        {
            return Goods.ToString() + ",goodsNum:" + GoodsNum;
        }

        public override bool Equals(object obj)
        {
            return obj is OrderDetails details &&
                   EqualityComparer<Goods>.Default.Equals(Goods, details.Goods) &&
                   GoodsNum == details.GoodsNum;
        }

        public override int GetHashCode()
        {
            int hashCode = -1633355496;
            hashCode = hashCode * -1521134295 + EqualityComparer<Goods>.Default.GetHashCode(Goods);
            hashCode = hashCode * -1521134295 + GoodsNum.GetHashCode();
            return hashCode;
        }
    }
}
